#define _CRT_SECURE_NO_WARNINGS 1
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);

    multimap<int, int> hash;
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        hash.insert({ v[i], i });
    }
    vector<int> flag(n);

    vector<int> Li;
    vector<int> Zhang;

    auto it = hash.begin();
    auto it2 = --hash.end();

    int record = 0;
    size_t book_sum = 0;
    while (book_sum < v.size())
    {
        if(record == 0)
        {
            int i = it->second;
          
            if(flag[i] == 0) {
                flag[i] = 1;
                Li.push_back(i + 1);
                int j = i - 1;
                int left_k = k;
                ++book_sum;
                while (book_sum < v.size() && left_k > 0 && j >= 0) {
                    if (flag[j] == 0) {
                        Li.push_back(j + 1);
                        flag[j] = 1;
                        --left_k;
                        ++book_sum;
                    }
                    --j;
                }
                j = i + 1;
                int right_k = k;
                while (book_sum < v.size() && right_k > 0 && j < v.size()){
                    if (flag[j] == 0)
                    {
                        Li.push_back(j + 1);
                        flag[j] = 1;
                        --right_k;
                        ++book_sum;
                    }
                    ++j;
                }
                record = 1;
            }
            ++it;
            
        }
        else 
        {
            int i = it2->second;

            if (flag[i] == 0) {
                flag[i] = 1;
                Zhang.push_back(i + 1);
                int j = i - 1;
                ++book_sum;
                int left_k = k;
                while (book_sum < v.size() && left_k > 0 && j >= 0) {
                    if (flag[j] == 0) {
                        Zhang.push_back(j + 1);
                        flag[j] = 1;
                        --left_k;
                        ++book_sum;
                    }
                    --j;
                }
                j = i + 1;
                int right_k = k;
                while (book_sum < v.size() && right_k > 0 && j < v.size()) {
                    if (flag[j] == 0)
                    {
                        Zhang.push_back(j + 1);
                        flag[j] = 1;
                        --right_k;
                        ++book_sum;
                    }
                    ++j;
                }
                record = 0;
            }
            --it2;
            
        }
    }
    sort(Li.begin(), Li.end());
    sort(Zhang.begin(), Zhang.end());
    for (auto i : Li)
    {
        cout << i << " ";
    }
    cout << endl;
    for (auto i : Zhang)
    {
        cout << i << " ";
    }

    return 0;
}